Kanzi  3.9.7
Kanzi Engine API
kanzi::BrushRenderer Class Referenceabstract

Brush renderer class. More...

#include <kanzi/core.ui/graphics2d/brush_renderer.hpp>

Inheritance diagram for kanzi::BrushRenderer:
[legend]

Public Types

enum  RenderMode { RenderModeNone, RenderModeContent, RenderModeNoContent }
 Enum signifying currently selected render mode. More...
 

Public Member Functions

MaterialSharedPtr acquireErrorMaterial ()
 Acquires an error material for rendering. More...
 
void attachMaterial (MaterialSharedPtr material)
 Attaches a custom material. More...
 
void bind (Renderer3D &renderer, PropertyObject *object)
 Binds a brush renderer for rendering. More...
 
void bind (Renderer3D &renderer)
 Bind brush renderer for rendering. More...
 
void draw (Renderer &renderer, const Geometry &quad, const Matrix4x4 &transform)
 Draw a brush using given quad. More...
 
void draw (Renderer &renderer, const Geometry &quad, const Matrix3x3 &transform)
 Overload for draw a brush using given quad. More...
 
int getBlendModeValue ()
 Gets the last used blend mode value. More...
 
BrushgetBrush () const
 Gets the brush for which Kanzi created this brush renderer. More...
 
TextureSharedPtr getContentTexture () const
 Access content texture. More...
 
MaterialSharedPtr getMaterial ()
 Gets the currently set material for the renderer. More...
 
NodegetNode () const
 Gets the attached node. More...
 
unsigned int getPropertyChangeCounter () const
 Gets the brush property change counter. More...
 
RenderMode getRenderMode () const
 Get currently selected render mode. More...
 
float getRenderOpacity () const
 Access opacity. More...
 
GlRenderStategetRenderState ()
 Gets the internal render state. More...
 
bool hasRenderMode () const
 Indicates whether a valid render mode is selected. More...
 
void invalidateRenderValues ()
 Invalidates all render values. More...
 
void restoreResources ()
 Restore resources after sleep. More...
 
void setContentTexture (TextureSharedPtr texture)
 Set a content texture. More...
 
void setRenderOpacity (float opacity)
 Set opacity to use for next attach. More...
 
void updateRender (optional< int > blendMode, bool translucencyHint)
 Called from Node2D::updateRender(). More...
 
virtual ~BrushRenderer ()=default
 Destructor. More...
 

Protected Member Functions

virtual void bindOverride (Renderer3D &renderer, PropertyObject *object)
 BrushRenderer-specific bind implementation. More...
 
 BrushRenderer (Brush *brush, Node *node)
 Constructor. More...
 
virtual void drawOverride (Renderer &renderer, const Geometry &geometry, const Matrix4x4 &transform)=0
 Draw geometry using the brush. More...
 
virtual bool isChangeCounterSame ()
 Checks whether the property change counter matches that of the brush. More...
 
virtual void restoreResourcesOverride ()
 BrushRenderer-specific restore resources implementation. More...
 
virtual void setContentTextureOverride (TextureSharedPtr texture)
 BrushRenderer-specific update of the content texture. More...
 
void setRenderMode (RenderMode selection)
 Set render mode. More...
 
virtual void updateChangeCounter ()
 Updates property change counter to match the counter value from brush. More...
 
virtual void updateRenderOverride (optional< int > blendMode, bool translucencyHint)=0
 BrushRenderer-specific opacity override implementation. More...
 

Protected Attributes

Brushm_brush
 Brush attached to. More...
 
unsigned int m_brushPropertyChangeCounter
 Property change counter to track brush. More...
 
TextureSharedPtr m_contentTexture
 Content texture provided to the brush renderer from outside. For example, from Node2D. More...
 
GlRenderState::HandleType m_contentTextureHandle
 Render value handle. More...
 
Nodem_node
 Node attached to. More...
 
RenderMode m_renderMode
 Currently used render mode (or none if not selected). More...
 
float m_renderOpacity
 Opacity to issue on attach. More...
 
GlRenderState::HandleType m_renderOpacityHandle
 Render value handle. More...
 
GlRenderState m_renderState
 Contained render state. More...
 
GlRenderValueBinding m_renderValueBinding
 Property binding handler. More...
 

Detailed Description

Brush renderer class.

Just an interface, actual rendering will be implemented by specialized brush renderers.

Member Enumeration Documentation

Enum signifying currently selected render mode.

Enumerator
RenderModeNone 

No selection.

RenderModeContent 

Content specified for brush.

Since
Kanzi 3.9.1
RenderModeNoContent 

No content specified for brush.

Since
Kanzi 3.9.1

Constructor & Destructor Documentation

virtual kanzi::BrushRenderer::~BrushRenderer ( )
virtualdefault

Destructor.

kanzi::BrushRenderer::BrushRenderer ( Brush brush,
Node node 
)
explicitprotected

Constructor.

Parameters
nodeThe node to which to attach.
brushThe brush to which to attach.

Member Function Documentation

void kanzi::BrushRenderer::updateRender ( optional< int >  blendMode,
bool  translucencyHint 
)
inline

Called from Node2D::updateRender().

Prepares a brush for rendering. Call this function when the brush material or attached nodes have changed. Unlike bind(), updateRender() does not need to be called every frame before draw().

Parameters
blendModeOptional blend mode override.
translucencyHintAdditional hint to use translucent rendering.
Since
Kanzi 3.9.1 added blendMode parameter.
Kanzi 3.9.6 removed forceOpaque parameter.
void kanzi::BrushRenderer::bind ( Renderer3D renderer,
PropertyObject object 
)
inline

Binds a brush renderer for rendering.

You must call this function before you call draw().

Parameters
rendererThe renderer to use.
objectThe object from which to fetch properties.
Since
Kanzi 3.9.7 moved here from MaterialBrushRenderer.
void kanzi::BrushRenderer::bind ( Renderer3D renderer)
inline

Bind brush renderer for rendering.

Must be called before calling draw().

Parameters
rendererRenderer to use.
void kanzi::BrushRenderer::draw ( Renderer renderer,
const Geometry quad,
const Matrix4x4 transform 
)

Draw a brush using given quad.

Parameters
rendererRenderer to use.
quadQuad to draw.
transformThe transform as a 4x4 matrix to use.
void kanzi::BrushRenderer::draw ( Renderer renderer,
const Geometry quad,
const Matrix3x3 transform 
)
inline

Overload for draw a brush using given quad.

Parameters
rendererRenderer to use.
quadQuad to draw.
transformThe transform as a 3x3 matrix to use.
void kanzi::BrushRenderer::restoreResources ( )
inline

Restore resources after sleep.

Brush* kanzi::BrushRenderer::getBrush ( ) const
inline

Gets the brush for which Kanzi created this brush renderer.

Returns
Brush pointer.
GlRenderState& kanzi::BrushRenderer::getRenderState ( )
inline

Gets the internal render state.

Returns
Reference to the render state.
Since
Kanzi 3.9.7
void kanzi::BrushRenderer::invalidateRenderValues ( )
inline

Invalidates all render values.

Since
Kanzi 3.9.7
MaterialSharedPtr kanzi::BrushRenderer::acquireErrorMaterial ( )

Acquires an error material for rendering.

Kanzi uses this function internally when the assigned material is not applicable.

Returns
Error material.
Since
Kanzi 3.9.7
unsigned int kanzi::BrushRenderer::getPropertyChangeCounter ( ) const
inline

Gets the brush property change counter.

Returns
Brush property change counter.
float kanzi::BrushRenderer::getRenderOpacity ( ) const
inline

Access opacity.

Returns
Current render opacity.
void kanzi::BrushRenderer::setRenderOpacity ( float  opacity)
inline

Set opacity to use for next attach.

Parameters
opacityNew render opacity.
TextureSharedPtr kanzi::BrushRenderer::getContentTexture ( ) const
inline

Access content texture.

Returns
Current content texture.
void kanzi::BrushRenderer::setContentTexture ( TextureSharedPtr  texture)
inline

Set a content texture.

Parameters
textureNew render texture.
Node* kanzi::BrushRenderer::getNode ( ) const
inline

Gets the attached node.

Returns
Node pointer.
RenderMode kanzi::BrushRenderer::getRenderMode ( ) const
inline

Get currently selected render mode.

Returns
Current render mode.
bool kanzi::BrushRenderer::hasRenderMode ( ) const
inline

Indicates whether a valid render mode is selected.

Returns
If a render mode has been selected, true, otherwise false.
MaterialSharedPtr kanzi::BrushRenderer::getMaterial ( )

Gets the currently set material for the renderer.

Returns
Shared pointer to the material that is currently set for the brush renderer. If not set, returns nullptr.
Since
Kanzi 3.9.7 made the function non-virtual.
int kanzi::BrushRenderer::getBlendModeValue ( )

Gets the last used blend mode value.

This function is intended for tests.

Returns
Blend mode.
Since
Kanzi 3.9.1
void kanzi::BrushRenderer::attachMaterial ( MaterialSharedPtr  material)

Attaches a custom material.

This function internally calls BrushRenderer::attachMaterial().

Parameters
materialThe material to attach.
Since
Kanzi 3.9.7 moved to the base class.
virtual void kanzi::BrushRenderer::drawOverride ( Renderer renderer,
const Geometry geometry,
const Matrix4x4 transform 
)
protectedpure virtual

Draw geometry using the brush.

To be implemented by specific brush implementations.

Parameters
rendererRenderer to use.
geometryQuad to draw.
transformTransform to use.

Implemented in kanzi::TextureBrushRenderer, kanzi::ColorBrushRenderer, kanzi::MaterialBrushRenderer, and kanzi::ContentBrushRenderer.

virtual void kanzi::BrushRenderer::bindOverride ( Renderer3D renderer,
PropertyObject object 
)
protectedvirtual

BrushRenderer-specific bind implementation.

Parameters
rendererRenderer to use.
objectThe object from which to fetch properties.
Since
Kanzi 3.9.7 added object.
virtual void kanzi::BrushRenderer::updateRenderOverride ( optional< int >  blendMode,
bool  translucencyHint 
)
protectedpure virtual

BrushRenderer-specific opacity override implementation.

Parameters
blendModeOptional blend mode override.
translucencyHintAdditional hint to use translucent rendering.
Since
Kanzi 3.9.1 added blendMode parameter.
Kanzi 3.9.6 removed forceOpaque parameter.

Implemented in kanzi::TextureBrushRenderer, kanzi::ColorBrushRenderer, kanzi::MaterialBrushRenderer, and kanzi::ContentBrushRenderer.

virtual void kanzi::BrushRenderer::restoreResourcesOverride ( )
protectedvirtual

BrushRenderer-specific restore resources implementation.

virtual void kanzi::BrushRenderer::setContentTextureOverride ( TextureSharedPtr  texture)
inlineprotectedvirtual

BrushRenderer-specific update of the content texture.

Parameters
textureNew renderer texture.
Since
Kanzi 3.9.5

Reimplemented in kanzi::ColorBrushRenderer.

void kanzi::BrushRenderer::setRenderMode ( RenderMode  selection)
inlineprotected

Set render mode.

Parameters
selectionNew render mode selection.
virtual bool kanzi::BrushRenderer::isChangeCounterSame ( )
protectedvirtual

Checks whether the property change counter matches that of the brush.

Returns
If the property change counter matches and no update is needed, true, otherwise false.
Since
Kanzi 3.9.7 made the function virtual.

Reimplemented in kanzi::MaterialBrushRenderer.

virtual void kanzi::BrushRenderer::updateChangeCounter ( )
protectedvirtual

Updates property change counter to match the counter value from brush.

Since
Kanzi 3.9.7 made the function virtual.

Reimplemented in kanzi::MaterialBrushRenderer.

Member Data Documentation

Brush* kanzi::BrushRenderer::m_brush
protected

Brush attached to.

Since
Kanzi 3.9.1 protection changed from private to protected.
Node* kanzi::BrushRenderer::m_node
protected

Node attached to.

RenderMode kanzi::BrushRenderer::m_renderMode
protected

Currently used render mode (or none if not selected).

GlRenderState kanzi::BrushRenderer::m_renderState
protected

Contained render state.

Since
Kanzi 3.9.7 moved to the base class.
GlRenderValueBinding kanzi::BrushRenderer::m_renderValueBinding
protected

Property binding handler.

Since
Kanzi 3.9.7 moved to the base class.
GlRenderState::HandleType kanzi::BrushRenderer::m_renderOpacityHandle
protected

Render value handle.

Since
Kanzi 3.9.7 moved to the base class.
GlRenderState::HandleType kanzi::BrushRenderer::m_contentTextureHandle
protected

Render value handle.

Since
Kanzi 3.9.7 moved to the base class.
TextureSharedPtr kanzi::BrushRenderer::m_contentTexture
protected

Content texture provided to the brush renderer from outside. For example, from Node2D.

float kanzi::BrushRenderer::m_renderOpacity
protected

Opacity to issue on attach.

unsigned int kanzi::BrushRenderer::m_brushPropertyChangeCounter
protected

Property change counter to track brush.


The documentation for this class was generated from the following file: